package com.easy.activiti;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class ActivitiPathMapping implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/");//默认也有这个路径映射
        registry.addResourceHandler("/workflow/**").addResourceLocations("classpath:/META-INF/resources/workflow/");
        registry.addResourceHandler("/bpmnjs/**").addResourceLocations("classpath:/META-INF/resources/bpmnjs/");

    }



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/activitiHistory/**")
                .addPathPatterns("/processInstance/**")
                .addPathPatterns("/task/**")
                .addPathPatterns("/user/**")
                .addPathPatterns("/activiti/**")
                .addPathPatterns("/processDefinition/**");
//                .excludePathPatterns("/public/**"); // 可以排除不需要拦截的路径
    }
}
